GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SetTagAttribute Method / SetTagAttribute(Int32,String,Double[]) Method
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
A name of the newly defined attribute to be attached to the specified tag's tree element.
A value of the newly defined attribute as an array of numbers, that is to be attached to the specified tag's tree element.
Example





SetTagAttribute(Int32,String,Double[]) Method
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree related to the currently loaded PDF document.

This attribute consists of a key-value pair: the key is the attribute's name and the value is the attribute's corresponding value. You are allowed to set the attribute's value as an array of numbers using this method.

Syntax
'Declaration
 
Public Overloads Function SetTagAttribute( _
   ByVal TagID As Integer, _
   ByVal Key As String, _
   ByVal Value() As Double _
) As GdPictureStatus
 

Parameters

TagID
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
Key
A name of the newly defined attribute to be attached to the specified tag's tree element.
Value
A value of the newly defined attribute as an array of numbers, that is to be attached to the specified tag's tree element.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to set the BBox attribute, which is necessary here, to a newly created tag attached to the image.
Dim caption As String = "Example: SetTagAttribute"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
        'This is required to have a valid PDF_UA document.
        gdpicturePDF.SetTitle("My first PDF/UA document")
        Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                Dim tagImage As Integer = gdpicturePDF.NewTag(tagRootID, "Figure")
                If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.SetTagAttribute(tagImage, "BBox", New Double() {0, 0, 612, 792}) = GdPictureStatus.OK) Then
                    If (gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") = GdPictureStatus.OK) AndAlso
                       (gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) = GdPictureStatus.OK) AndAlso
                       (gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
                        Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
                        If status = GdPictureStatus.OK Then
                            MessageBox.Show("Your new PDF document has been successfully created.", caption)
                        Else
                            MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
                        End If
                    Else
                        MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
                    End If
                Else
                    MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
        gdpicturePDF.CloseDocument()
    Else
        MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
End Using
See Also